
export class SpriteStoreManager
{
    private static sprites:Array<cc.Sprite> = [];
    public static Store(sp:cc.Sprite):void
    {
        if(!sp)return;
        if(this.sprites.indexOf(sp)==-1)
        {
            this.sprites.push(sp);
            sp.node.x = 0;
            sp.node.y = 0;
            sp.node.scaleX = 1;
            sp.node.scaleY = 1;
            sp.sizeMode = cc.Sprite.SizeMode.TRIMMED;
            sp.spriteFrame = null;
            
            if(sp.node.parent)
                sp.node.removeFromParent();
        }
    }
    public static New(name?:string):cc.Sprite
    {
        let sp:cc.Sprite;
        if(this.sprites.length>0)
        {
            sp = this.sprites.shift();
            sp.node.opacity = 255;
        }else
        {
            let n = new cc.Node();
            sp = n.addComponent(cc.Sprite);
        }
        sp.node.name = name?name:"Sprite";
        return sp;
    }
}
